﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace PM.Web.Admin
{
    public partial class admin_dept_list : System.Web.UI.Page
    {
        public int RecordNum;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bindDDL();
                bindData();
            }
        }

        private void bindDDL()
        {
            DataAccess.PmData dal = new DataAccess.PmData();
            this.ddlColList.DataSource = dal.GetColtd(int.Parse(Session["ColtdId"].ToString()), true);
            this.ddlColList.DataBind();
        }

        private void bindData()
        {
            DataAccess.PmData dal = new DataAccess.PmData();
            System.Data.DataTable dt = new System.Data.DataTable();
            dt = dal.GetCommunity(int.Parse(Session["CommId"].ToString()), true);
            AspNetPager1.RecordCount = dt.Rows.Count; RecordNum = dt.Rows.Count;
            PagedDataSource pds = new PagedDataSource();
            pds.AllowPaging = true;
            pds.PageSize = AspNetPager1.PageSize;
            pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
            pds.DataSource = dt.DefaultView;
            this.repDeptList.DataSource = dal.GetDept(int.Parse(this.ddlColList.SelectedValue), null, true);
            this.repDeptList.DataBind();
        }

        protected void lnkQuery_Click(object sender, EventArgs e)
        {
            bindData();
        }

        protected void btnReload_Click(object sender, EventArgs e)
        {
            bindData();
        }

        protected void ddlColList_SelectedIndexChanged(object sender, EventArgs e)
        {
            bindData();
        }
        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            bindData();
        }  
    }
}